home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / esc.jar / com / extensibility / xml / ContentModelTerm.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-30  |  16.6 KB  |  812 lines

  1. package com.extensibility.xml;
  2.  
  3. import com.extensibility.util.Debug;
  4. import com.extensibility.util.RUtils;
  5. import com.extensibility.util.regexpr.PatternTerm;
  6. import java.util.Enumeration;
  7. import java.util.Hashtable;
  8. import java.util.Vector;
  9. import javax.swing.event.ChangeListener;
  10.  
  11. public class ContentModelTerm implements Cloneable, QualifiedName, DeclRef.SourceIntf, PatternTerm {
  12.    public static final char EXACTLY_ONCE = '\u0000';
  13.    public static final char OPTIONAL = '?';
  14.    public static final char ONE_OR_MORE = '+';
  15.    public static final char ZERO_OR_MORE = '*';
  16.    public static final char SEQ = ',';
  17.    public static final char CHOICE = '|';
  18.    protected static final String EMPTY = "#EMPTY";
  19.    protected static final String ANY = "#ANY";
  20.    protected static final String PCDATA = "#PCDATA";
  21.    protected static final TypeRef GROUP = null;
  22.    public static final int TYPE_PCDATA = 1;
  23.    public static char TAG_TYPE_SEPARATOR = '=';
  24.    TypeRef term;
  25.    String localTag;
  26.    char occurance;
  27.    char connection;
  28.    Vector groupContents;
  29.    int minOccurs;
  30.    int maxOccurs;
  31.    boolean occuranceOnly;
  32.    ContentModelTerm parent;
  33.    ContentModelOwner owner;
  34.    private static final String DEFAULT_NAME = "Content Model";
  35.    ChangeListener changer;
  36.  
  37.    public static char combineOccurances(char var0, char var1) {
  38.       boolean var2 = var1 == '?' || var1 == '*' || var0 == '?' || var0 == '*';
  39.       boolean var3 = var1 == '*' || var1 == '+' || var0 == '*' || var0 == '+';
  40.       if (var2) {
  41.          return (char)(var3 ? '*' : '?');
  42.       } else {
  43.          return (char)(var3 ? '+' : '\u0000');
  44.       }
  45.    }
  46.  
  47.    public ContentModelTerm(TypeRef var1) {
  48.       this(var1, 1, 1, ',');
  49.    }
  50.  
  51.    public ContentModelTerm(TypeRef var1, char var2, char var3) {
  52.       this(var1, 1, 1, var3);
  53.       this.setOccurance(var2);
  54.    }
  55.  
  56.    public ContentModelTerm(TypeRef var1, int var2, int var3, char var4) {
  57.       this.occurance = 0;
  58.       this.connection = ',';
  59.       this.minOccurs = 1;
  60.       this.maxOccurs = 1;
  61.       this.changer = new 1(this);
  62.       Debug.assert(!((DeclRef)var1).equals("#PCDATA"), "#PCDATA should be set using a different constructor.");
  63.       this.setTerm(var1);
  64.       this.setOccurance(var2, var3);
  65.       this.connection = var4;
  66.       this.checkOccurance();
  67.       this.checkConnection();
  68.    }
  69.  
  70.    public ContentModelTerm(char var1, char var2) {
  71.       this();
  72.       this.occurance = var1;
  73.       this.connection = var2;
  74.       this.checkOccurance();
  75.       this.checkConnection();
  76.    }
  77.  
  78.    public ContentModelTerm() {
  79.       this.occurance = 0;
  80.       this.connection = ',';
  81.       this.minOccurs = 1;
  82.       this.maxOccurs = 1;
  83.       this.changer = new 1(this);
  84.       this.groupContents = new Vector();
  85.       this.term = GROUP;
  86.    }
  87.  
  88.    protected ContentModelTerm(int var1) {
  89.       this.occurance = 0;
  90.       this.connection = ',';
  91.       this.minOccurs = 1;
  92.       this.maxOccurs = 1;
  93.       this.changer = new 1(this);
  94.       if (var1 == 3) {
  95.          this.term = new TypeRef("#EMPTY");
  96.       } else if (var1 == 2) {
  97.          this.term = new TypeRef("#ANY");
  98.       } else {
  99.          if (var1 != 1) {
  100.             throw new IllegalArgumentException();
  101.          }
  102.  
  103.          this.term = new TypeRef("#PCDATA");
  104.          this.connection = '|';
  105.       }
  106.  
  107.    }
  108.  
  109.    public Object clone() throws CloneNotSupportedException {
  110.       throw new CloneNotSupportedException();
  111.    }
  112.  
  113.    protected Object clone(boolean var1) {
  114.       try {
  115.          ContentModelTerm var2 = (ContentModelTerm)super.clone();
  116.          if (var1 && this.groupContents != null) {
  117.             var2.groupContents = new Vector();
  118.             Enumeration var6 = this.groupContents.elements();
  119.  
  120.             while(var6.hasMoreElements()) {
  121.                ContentModelTerm var4 = (ContentModelTerm)var6.nextElement();
  122.                var2.groupContents.addElement(var4.clone(var1));
  123.             }
  124.          }
  125.  
  126.          return var2;
  127.       } catch (CloneNotSupportedException var5) {
  128.          Debug.assert(false, "Problem cloning ContentModelTerm.");
  129.          Object var3 = null;
  130.          return var3;
  131.       }
  132.    }
  133.  
  134.    private Object clone(int[] var1) {
  135.       ContentModelTerm var2 = (ContentModelTerm)this.clone(false);
  136.       var2.minOccurs = var1[0];
  137.       var2.maxOccurs = var1[1];
  138.       return var2;
  139.    }
  140.  
  141.    public Object clone(ContentModelOwner var1) {
  142.       ContentModelTerm var2 = null;
  143.  
  144.       try {
  145.          var2 = (ContentModelTerm)super.clone();
  146.          var2.owner = var1;
  147.          if (this.groupContents != null) {
  148.             var2.groupContents = new Vector();
  149.             Enumeration var3 = this.groupContents.elements();
  150.  
  151.             while(var3.hasMoreElements()) {
  152.                ContentModelTerm var4 = (ContentModelTerm)var3.nextElement();
  153.                if (var4.owner != null) {
  154.                   var2.addTerm(var4);
  155.                } else {
  156.                   var2.addTerm((ContentModelTerm)var4.clone((ContentModelOwner)null));
  157.                }
  158.             }
  159.          } else {
  160.             var2.term = new TypeRef(this.term.getName());
  161.          }
  162.       } catch (CloneNotSupportedException var5) {
  163.          Debug.assert(false, "Problem cloning ContentModelTerm.");
  164.       }
  165.  
  166.       return var2;
  167.    }
  168.  
  169.    protected void visitChildren(Visitor var1, Hashtable var2, boolean var3) {
  170.       if (this.groupContents != null && !var2.contains(this)) {
  171.          var2.put(this, this);
  172.          ContentModelTermEnum var4 = this.getTerms(var3);
  173.  
  174.          while(var4.hasMoreElements()) {
  175.             ContentModelTerm var5 = var4.nextContentModelTerm();
  176.             var1.visit(var5);
  177.             if (var3 || !(var5.owner instanceof InternalPEDeclaration)) {
  178.                var5.visitChildren(var1, var2, var3);
  179.             }
  180.          }
  181.       }
  182.  
  183.    }
  184.  
  185.    public final char getOccurance() {
  186.       this.checkOccurance();
  187.       return this.isHidden() && this.firstTerm() != null ? this.firstTerm().getOccurance() : this.occurance;
  188.    }
  189.  
  190.    public int getMinOccurance() {
  191.       return this.minOccurs;
  192.    }
  193.  
  194.    public int getMaxOccurance() {
  195.       return this.maxOccurs;
  196.    }
  197.  
  198.    public char getConnection() {
  199.       this.checkConnection();
  200.       return (this.isHidden() || this.isGroup() && this.parent == null || this.isOccuranceOnly()) && this.groupContents.size() > 0 ? this.firstTerm().getConnection() : this.connection;
  201.    }
  202.  
  203.    char getConnection(boolean var1) {
  204.       this.checkConnection();
  205.       if ((this.isHidden() || this.isOccuranceOnly()) && this.groupContents.size() > 0) {
  206.          return this.firstTerm().getConnection(var1);
  207.       } else if (var1 && this.getParent() != null) {
  208.          return this.getParent().isLast(this) ? '\u0000' : this.connection;
  209.       } else {
  210.          return this.connection;
  211.       }
  212.    }
  213.  
  214.    private boolean isLast(ContentModelTerm var1) {
  215.       return this.isGroup() && this.groupContents.size() == 1 || this.groupContents.indexOf(var1) == this.groupContents.size() - 1;
  216.    }
  217.  
  218.    public void setChoice() {
  219.       if (!this.isGroup()) {
  220.          this.updateModelTerm();
  221.       }
  222.  
  223.       this.setChildConnection('|');
  224.       this.setOccurance('\u0000');
  225.    }
  226.  
  227.    public void setSeq() {
  228.       if (!this.isGroup()) {
  229.          this.updateModelTerm();
  230.       }
  231.  
  232.       this.setChildConnection(',');
  233.    }
  234.  
  235.    public void setChildConnection(char var1) {
  236.       char var2 = this.getChildConnection();
  237.       Enumeration var3 = this.terms();
  238.  
  239.       while(var3.hasMoreElements()) {
  240.          ((ContentModelTerm)var3.nextElement()).setConnection(var1);
  241.       }
  242.  
  243.       this.fireChangeEvent(26, new Character(var2));
  244.    }
  245.  
  246.    public boolean isOptional() {
  247.       return this.getOccurance() == '?' || this.getOccurance() == '*';
  248.    }
  249.  
  250.    public boolean isRepeatable() {
  251.       return this.getOccurance() == '*' || this.getOccurance() == '+';
  252.    }
  253.  
  254.    public void setOptional(boolean var1) {
  255.       if (var1) {
  256.          this.setOccurance(0, this.getMaxOccurance());
  257.       } else {
  258.          this.setOccurance(1, Math.max(1, this.getMaxOccurance()));
  259.       }
  260.  
  261.    }
  262.  
  263.    public void setRepeatable(boolean var1) {
  264.       if (var1) {
  265.          this.setOccurance(this.getMinOccurance(), Integer.MAX_VALUE);
  266.       } else {
  267.          this.setOccurance(Math.min(this.getMinOccurance(), 1), 1);
  268.       }
  269.  
  270.    }
  271.  
  272.    public boolean isChoice() {
  273.       return this.isGroup() && this.getChildConnection() == '|';
  274.    }
  275.  
  276.    public boolean isSeq() {
  277.       return this.isGroup() && this.getChildConnection() == ',';
  278.    }
  279.  
  280.    public boolean isMany() {
  281.       return this.isChoice() && this.getOccurance() == '*';
  282.    }
  283.  
  284.    boolean changeTermQuietly(String var1, String var2) {
  285.       boolean var3 = false;
  286.       boolean var6;
  287.       if (this.isGroup()) {
  288.          for(Enumeration var4 = this.terms(); var4.hasMoreElements(); var3 |= var6) {
  289.             ContentModelTerm var5 = (ContentModelTerm)var4.nextElement();
  290.             var6 = var5.changeTermQuietly(var1, var2);
  291.          }
  292.       } else if (this.term.equals(var1)) {
  293.          this.term.setName(var2);
  294.          var3 = true;
  295.       }
  296.  
  297.       return var3;
  298.    }
  299.  
  300.    public char getChildConnection() {
  301.       Debug.assert(this.isGroup(), "getChildConnection only valid for groups.");
  302.       return this.groupContents.isEmpty() ? ',' : ((ContentModelTerm)this.groupContents.firstElement()).getConnection();
  303.    }
  304.  
  305.    public char getChildConnection(boolean var1) {
  306.       char var2 = this.getChildConnection();
  307.       if (var1 && this.groupContents.size() <= 1) {
  308.          var2 = 0;
  309.       }
  310.  
  311.       return var2;
  312.    }
  313.  
  314.    public void setOccurance(int var1, int var2) {
  315.       this.minOccurs = var1;
  316.       this.maxOccurs = var2;
  317.       this.checkOccurance();
  318.       if (this.minOccurs == 0) {
  319.          this.occurance = (char)(this.maxOccurs == 1 ? 63 : 42);
  320.       } else if (this.minOccurs == 1) {
  321.          this.occurance = (char)(this.maxOccurs == 1 ? 0 : 43);
  322.       } else {
  323.          this.occurance = '+';
  324.       }
  325.  
  326.       this.fireChangeEvent(24, new int[]{var1, var2});
  327.    }
  328.  
  329.    public void setOccurance(char var1) {
  330.       char var2 = this.occurance;
  331.       this.occurance = var1;
  332.       this.minOccurs = var1 != '+' && var1 != 0 ? 0 : 1;
  333.       this.maxOccurs = var1 != '+' && var1 != '*' ? 1 : Integer.MAX_VALUE;
  334.       this.checkOccurance();
  335.       this.fireChangeEvent(24, new Character(var2));
  336.    }
  337.  
  338.    protected void checkOccurance() {
  339.       Debug.assert(this.occurance == 0 || this.occurance == '*' || this.occurance == '+' || this.occurance == '?', String.valueOf("Occurance invalid: ").concat(String.valueOf(this.occurance)));
  340.    }
  341.  
  342.    public boolean isTermReference() {
  343.       return !this.isGroup() && !this.term.equals("#EMPTY") && !this.term.equals("#ANY") && !this.term.equals("#PCDATA") && this.term.getName().length() > 0 && this.term.getName().charAt(0) != '%';
  344.    }
  345.  
  346.    public ContentModelTerm firstTerm() {
  347.       return this.groupContents != null && this.groupContents.size() != 0 ? (ContentModelTerm)this.groupContents.firstElement() : null;
  348.    }
  349.  
  350.    void updateModelTerm(TypeRef var1) {
  351.       if (this.isGroup()) {
  352.          this.removeAll();
  353.          this.groupContents = null;
  354.       }
  355.  
  356.       this.setTerm(var1);
  357.       this.fireChangeEvent(23, this);
  358.    }
  359.  
  360.    void updateModelTerm() {
  361.       if (this.isGroup()) {
  362.          this.removeAll();
  363.       } else {
  364.          this.groupContents = new Vector();
  365.       }
  366.  
  367.       this.term = GROUP;
  368.       this.fireChangeEvent(22, (Object)null);
  369.    }
  370.  
  371.    public void setConnection(char var1) {
  372.       char var2 = this.connection;
  373.       this.connection = var1;
  374.       this.checkConnection();
  375.       this.fireChangeEvent(25, new Character(var2));
  376.    }
  377.  
  378.    protected void checkConnection() {
  379.       Debug.assert(this.connection == ',' || this.connection == '|', String.valueOf("Connection invalid: ").concat(String.valueOf(this.connection)));
  380.    }
  381.  
  382.    public String getTerm() {
  383.       return this.isGroup() ? this.getOccuranceAsString(true, true) : this.term.getName();
  384.    }
  385.  
  386.    public TypeRef getTermRef() {
  387.       return this.term;
  388.    }
  389.  
  390.    public String getLocalTag() {
  391.       return this.localTag;
  392.    }
  393.  
  394.    public void setLocalTag(String var1) {
  395.       if (var1 != this.localTag) {
  396.          String var2 = this.getTerm();
  397.          this.localTag = var1;
  398.          this.fireChangeEvent(20, var2);
  399.       }
  400.    }
  401.  
  402.    public String getPrefix() {
  403.       return this.term.getPrefix();
  404.    }
  405.  
  406.    public String getNCName() {
  407.       return this.term.getNCName();
  408.    }
  409.  
  410.    public boolean isQualified() {
  411.       return this.term.isQualified();
  412.    }
  413.  
  414.    public boolean isPCDATATerm() {
  415.       return this.term != null && this.term.equals("#PCDATA");
  416.    }
  417.  
  418.    public boolean isAnyTerm() {
  419.       return this.term != null && this.term.equals("#ANY");
  420.    }
  421.  
  422.    public boolean isEmptyTerm() {
  423.       return this.term != null && this.term.equals("#EMPTY");
  424.    }
  425.  
  426.    protected void setTerm(TypeRef var1) {
  427.       Debug.assert(!this.isGroup(), "can't set term of group");
  428.       TypeRef var2 = this.term;
  429.       this.term = var1;
  430.       if (var2 != null) {
  431.          if (((DeclRef)var2).isBound()) {
  432.             ((DeclRef)var2).release();
  433.          }
  434.  
  435.          ((DeclRef)var2).removeChangeListener(this.changer);
  436.       }
  437.  
  438.       if (this.getOwner() != null && this.getOwner().asDecl().getSchema() != null) {
  439.          this.term.bind(this.getOwner().asDecl().getSchema(), this);
  440.       }
  441.  
  442.       this.term.addChangeListener(this.changer);
  443.       this.fireChangeEvent(20, var2);
  444.    }
  445.  
  446.    public Vector getUsesList(Vector var1) {
  447.       if (var1 == null) {
  448.          var1 = new Vector();
  449.       }
  450.  
  451.       if (this.groupContents == null) {
  452.          return var1;
  453.       } else {
  454.          for(int var2 = 0; var2 < this.groupContents.size(); ++var2) {
  455.             ContentModelTerm var3 = (ContentModelTerm)this.groupContents.elementAt(var2);
  456.             if (var3.isGroup()) {
  457.                var3.getUsesList(var1);
  458.             }
  459.  
  460.             if (var3.isOwned()) {
  461.                var1.addElement(var3.getOwner());
  462.             }
  463.          }
  464.  
  465.          return var1;
  466.       }
  467.    }
  468.  
  469.    public boolean contains(String var1) {
  470.       if (this.isGroup()) {
  471.          Enumeration var2 = this.terms();
  472.  
  473.          while(var2.hasMoreElements()) {
  474.             ContentModelTerm var3 = (ContentModelTerm)var2.nextElement();
  475.             if (var3.contains(var1)) {
  476.                return true;
  477.             }
  478.          }
  479.  
  480.          return false;
  481.       } else {
  482.          return this.term != null && this.term.equals(var1);
  483.       }
  484.    }
  485.  
  486.    public boolean groupContains(String var1) {
  487.       Debug.assert(this.isGroup(), "only applies to a group");
  488.       Enumeration var2 = this.terms();
  489.  
  490.       while(var2.hasMoreElements()) {
  491.          ContentModelTerm var3 = (ContentModelTerm)var2.nextElement();
  492.          if (var3.term != null && var3.term.equals(var1)) {
  493.             return true;
  494.          }
  495.       }
  496.  
  497.       return false;
  498.    }
  499.  
  500.    public boolean isOwned() {
  501.       return false;
  502.    }
  503.  
  504.    public ContentModelOwner getOwner() {
  505.       return this.parent == null ? null : this.getParent().getOwner();
  506.    }
  507.  
  508.    void setParent(ContentModelTerm var1) {
  509.       this.parent = var1;
  510.    }
  511.  
  512.    public void subjugateTerm(ContentModelTerm var1, ContentModelTerm var2) {
  513.       Debug.assert(var1.isOwned(), "only works when existing term is owned");
  514.       Debug.assert(!var2.isOwned(), "only works when newTerm term is not owned");
  515.       if (var2 != var1) {
  516.          this.groupContents.removeElement(var1);
  517.          var2.groupContents.addElement(var1);
  518.          var2.occuranceOnly = true;
  519.          this.groupContents.addElement(var2);
  520.          var2.setParent(this);
  521.       }
  522.    }
  523.  
  524.    public boolean isOccuranceOnly() {
  525.       return this.occuranceOnly;
  526.    }
  527.  
  528.    private boolean isHidden() {
  529.       return this.owner != null;
  530.    }
  531.  
  532.    public boolean isGroup() {
  533.       return this.groupContents != null;
  534.    }
  535.  
  536.    private void removeNotifier(ContentModelOwner var1) {
  537.       if (this.isOwned()) {
  538.          if (var1 != null) {
  539.             var1.unuseNotify(this.getOwner());
  540.             this.getOwner().unusedByNotify(var1);
  541.          }
  542.       } else if (this.isGroup()) {
  543.          for(int var2 = 0; var2 < this.groupContents.size(); ++var2) {
  544.             ((ContentModelTerm)this.groupContents.elementAt(var2)).removeNotifier(this.getOwner());
  545.          }
  546.       }
  547.  
  548.       if (this.term != null) {
  549.          if (this.term.isBound()) {
  550.             this.term.release();
  551.          }
  552.  
  553.          this.term.removeChangeListener(this.changer);
  554.       }
  555.  
  556.    }
  557.  
  558.    public void removeAll() {
  559.       if (this.isGroup()) {
  560.          for(int var1 = this.groupContents.size() - 1; var1 >= 0; --var1) {
  561.             this.removeTerm((ContentModelTerm)this.groupContents.elementAt(var1));
  562.          }
  563.  
  564.       }
  565.    }
  566.  
  567.    public void removeTerm(ContentModelTerm var1) {
  568.       this.groupContents.removeElement(var1);
  569.       var1.removeNotifier(this.getOwner());
  570.       if (!var1.isOwned()) {
  571.          var1.setParent((ContentModelTerm)null);
  572.       }
  573.  
  574.       this.fireChangeEvent(22, var1);
  575.    }
  576.  
  577.    private void addNotifier(ContentModelOwner var1) {
  578.       if (this.isOwned()) {
  579.          if (var1 != null) {
  580.             var1.useNotify(this.getOwner());
  581.             this.getOwner().usedByNotify(var1);
  582.          }
  583.       } else if (this.isGroup()) {
  584.          for(int var2 = 0; var2 < this.groupContents.size(); ++var2) {
  585.             ((ContentModelTerm)this.groupContents.elementAt(var2)).addNotifier(this.getOwner());
  586.          }
  587.       }
  588.  
  589.       if (this.term != null) {
  590.          if (!this.term.isBound() && this.getOwner() != null && this.getOwner().asDecl().getSchema() != null) {
  591.             this.term.bind(this.getOwner().asDecl().getSchema(), this);
  592.          }
  593.  
  594.          this.term.addChangeListener(this.changer);
  595.       }
  596.  
  597.    }
  598.  
  599.    void replaceTerm(ContentModelTerm var1, ContentModelTerm var2) {
  600.       int var3 = this.groupContents.indexOf(var1);
  601.       this.removeTerm(var1);
  602.       this.addTerm(var2);
  603.       this.groupContents.removeElement(var2);
  604.       this.groupContents.insertElementAt(var2, var3);
  605.    }
  606.  
  607.    public void addTerm(ContentModelTerm var1) {
  608.       Debug.assert(this.owner != null || !var1.isEmptyTerm() && !var1.isAnyTerm(), "Empty and Any terms must reside only at the top level");
  609.       if (this.isAnyTerm()) {
  610.          this.groupContents = new Vector();
  611.          this.term = GROUP;
  612.          this.addTerm(new ContentModelTerm(1));
  613.          this.setOccurance('*');
  614.       }
  615.  
  616.       if (this.isEmptyTerm()) {
  617.          this.groupContents = new Vector();
  618.          this.term = GROUP;
  619.       }
  620.  
  621.       this.groupContents.addElement(var1);
  622.       if (!var1.isOwned()) {
  623.          var1.setParent(this);
  624.       }
  625.  
  626.       var1.addNotifier(this.getOwner());
  627.       this.fireChangeEvent(21, var1);
  628.    }
  629.  
  630.    void prependTerm(ContentModelTerm var1) {
  631.       this.groupContents.insertElementAt(var1, 0);
  632.       if (!var1.isOwned()) {
  633.          var1.setParent(this);
  634.       }
  635.  
  636.       var1.addNotifier(this.getOwner());
  637.       this.fireChangeEvent(21, var1);
  638.    }
  639.  
  640.    public void fireChangeEvent(int var1, Object var2) {
  641.       ContentModelOwner var3 = this.getOwner();
  642.       if (var3 != null) {
  643.          var3.modelStateChanged(this, var1, var2);
  644.       }
  645.  
  646.    }
  647.  
  648.    protected Enumeration terms() {
  649.       return this.groupContents != null ? this.groupContents.elements() : RUtils.createEmptyEnum();
  650.    }
  651.  
  652.    public int getLeafCount() {
  653.       if (!this.isGroup()) {
  654.          return 0;
  655.       } else {
  656.          ContentModelTermEnum var1 = this.getLeafTerms();
  657.  
  658.          int var2;
  659.          for(var2 = 0; var1.hasMoreElements(); ++var2) {
  660.             var1.nextElement();
  661.          }
  662.  
  663.          return var2;
  664.       }
  665.    }
  666.  
  667.    public ContentModelTermEnum getLeafTerms() {
  668.       return new 1.MyEnum(this);
  669.    }
  670.  
  671.    public ContentModelTermEnum getTerms(boolean var1) {
  672.       return var1 ? this.getEffectiveTerms() : this.getTerms();
  673.    }
  674.  
  675.    private ContentModelTermEnum getEffectiveTerms() {
  676.       return new 2.EffTermEnum(this);
  677.    }
  678.  
  679.    private ContentModelTermEnum getTerms() {
  680.       return new 3.TermEnum(this);
  681.    }
  682.  
  683.    public ContentModelTerm getParent() {
  684.       return this.parent;
  685.    }
  686.  
  687.    public String toString() {
  688.       return this.getSource(false);
  689.    }
  690.  
  691.    public String getSource(boolean var1) {
  692.       return this.getSource(new FormatOptions(0, var1), true);
  693.    }
  694.  
  695.    public String getSource(int var1) {
  696.       return this.getLeafCount() == 0 ? "EMPTY" : this.getSource(new FormatOptions(var1, true), true);
  697.    }
  698.  
  699.    private String getSource(FormatOptions var1, boolean var2) {
  700.       this.checkConnection();
  701.       this.checkOccurance();
  702.       if (!var2 && this.isOwned() && this.getOwner() instanceof InternalPEDeclaration && !var1.expandPERefs) {
  703.          return String.valueOf(String.valueOf("%").concat(String.valueOf(this.getOwner().getName()))).concat(String.valueOf(var1.peRefTerminator));
  704.       } else if (this.isGroup()) {
  705.          boolean var10 = this.occuranceOnly || this.isHidden();
  706.          StringBuffer var4 = new StringBuffer(var10 ? "" : " (");
  707.          boolean var5 = true;
  708.          Enumeration var6 = this.terms();
  709.          char var7 = 0;
  710.  
  711.          while(var6.hasMoreElements()) {
  712.             ContentModelTerm var8 = (ContentModelTerm)var6.nextElement();
  713.             String var9 = var8.getSource(var1.getOptionsForNextLevel(), false);
  714.             if (!var5) {
  715.                var4.append(String.valueOf(String.valueOf(var1.newTerm).concat(String.valueOf(var7))).concat(String.valueOf(" ")));
  716.             } else if (var1.justElements && var8.isPCDATATerm()) {
  717.                var9 = "";
  718.             } else {
  719.                var5 = false;
  720.             }
  721.  
  722.             var7 = var8.connection;
  723.             var4.append(var9);
  724.          }
  725.  
  726.          var4.append(var10 ? "" : String.valueOf(" )").concat(String.valueOf(this.getOccuranceAsString(var1.allowKleene, var1.allowMinMax, true))));
  727.          return var4.toString();
  728.       } else if (this.term.equals("#EMPTY")) {
  729.          return "EMPTY";
  730.       } else if (this.term.equals("#ANY")) {
  731.          return "ANY";
  732.       } else {
  733.          String var3 = this.getOccuranceAsString(var1.allowKleene, var1.allowMinMax, true);
  734.          return this.getLocalTag() != null && var1.forDisplay ? String.valueOf(String.valueOf(String.valueOf(this.getLocalTag()).concat(String.valueOf(TAG_TYPE_SEPARATOR))).concat(String.valueOf(this.getTerm()))).concat(String.valueOf(var3)) : String.valueOf(this.getTerm()).concat(String.valueOf(var3));
  735.       }
  736.    }
  737.  
  738.    public String getOccuranceAsString() {
  739.       return this.getOccuranceAsString(true, false);
  740.    }
  741.  
  742.    public String getOccuranceAsString(boolean var1, boolean var2, boolean var3) {
  743.       String var4 = this.getOccuranceAsString(var1, var2);
  744.       if (var3 && var4.length() > 1) {
  745.          var4 = String.valueOf(String.valueOf("{").concat(String.valueOf(var4))).concat(String.valueOf("}"));
  746.       }
  747.  
  748.       return var4;
  749.    }
  750.  
  751.    public String getOccuranceAsString(boolean var1, boolean var2) {
  752.       this.checkOccurance();
  753.       if (!var2 || var1 && this.minOccurs <= 1 && (this.maxOccurs <= 1 || this.maxOccurs == Integer.MAX_VALUE)) {
  754.          Debug.assert(var1, "nothing allowed!");
  755.          return this.occurance == 0 ? "" : (new Character(this.occurance)).toString();
  756.       } else {
  757.          return String.valueOf(String.valueOf(this.minOccurs).concat(String.valueOf(","))).concat(String.valueOf(this.maxOccurs < Integer.MAX_VALUE ? (new Integer(this.maxOccurs)).toString() : "*"));
  758.       }
  759.    }
  760.  
  761.    public static String getTypeName(String var0) {
  762.       int var1 = var0.indexOf(TAG_TYPE_SEPARATOR);
  763.       return var1 == -1 ? var0 : var0.substring(var1 + 1);
  764.    }
  765.  
  766.    public CMTReferent getReferent() {
  767.       return this.term == null ? null : this.term.getTargetCMTReferent();
  768.    }
  769.  
  770.    public Enumeration getPatternTerms() {
  771.       return this.getTerms(true);
  772.    }
  773.  
  774.    public boolean matches(String var1) {
  775.       Debug.assert(!this.isGroup());
  776.       return var1.equals(this.getTerm());
  777.    }
  778.  
  779.    public boolean intersects(PatternTerm var1) {
  780.       ContentModelTerm var2 = (ContentModelTerm)var1;
  781.       return !this.isGroup() && !var2.isGroup() && this.matches(var2.getTerm());
  782.    }
  783.  
  784.    public int getMinOccurrence() {
  785.       return this.getMinOccurance();
  786.    }
  787.  
  788.    public int getMaxOccurrence() {
  789.       return this.getMaxOccurance();
  790.    }
  791.  
  792.    // $FF: synthetic method
  793.    static ContentModelTermEnum access$1000371(ContentModelTerm var0) {
  794.       return var0.getTerms();
  795.    }
  796.  
  797.    // $FF: synthetic method
  798.    static ContentModelTermEnum access$1000071(ContentModelTerm var0) {
  799.       return var0.getEffectiveTerms();
  800.    }
  801.  
  802.    // $FF: synthetic method
  803.    static boolean access$1000271(ContentModelTerm var0) {
  804.       return var0.isHidden();
  805.    }
  806.  
  807.    // $FF: synthetic method
  808.    static Object access$1000171(ContentModelTerm var0, int[] var1) {
  809.       return var0.clone(var1);
  810.    }
  811. }
  812.